import org.junit.Test;

import edu.purdue.cs.cs180.channel.MessageListener;
import edu.purdue.cs.cs180.channel.TCPChannel;

/**
 * project6
 * 
 * brief description of the program
 * 
 * This program is released to public domain according to author's wish, you can
 * view full license at http://tomatoeskit.org/upload/PublicDomainLicense.txt
 * 
 * @author Fangning CHENG (Alpha.L Cheng) <chengf@purdue.edu>
 * 
 * @lab section number
 * 
 * @date Oct 24, 2013
 * 
 */

public class TestServer implements MessageListener {
    TCPChannel c1;
    int        id;

    @Test
    public void testServer() {
        try {
            System.out.println("TEST BEGINS");
            TCPChannel channel = new TCPChannel(5800);
            Server srv = new LocBasedServer(channel);

            c1 = new TCPChannel("localhost", 5800);
            c1.setMessageListener(this);
            id = c1.getID();

            Thread.sleep(5000);

            srv.messageReceived("VOLUNTEER LWSN", id);
            srv.messageReceived("VOLUNTEER PUSH", id);
            
            
            srv.messageReceived("REQUEST EE NORMAL", id);

        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            Thread.sleep(50000000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void messageReceived(String message, int clientID) {
        System.out.println("Message from " + clientID + ": " + message);
    }
}
